From cc878160bd2dc1fc4cc2c241fec6805c6dcb716d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 1 Jun 2020 00:10:42 -0400 Subject: [PATCH] gtk-demo: Fix a crash in the puzzle Avoid a crash when clicking the refresh button after solving the puzzle. --- demos/gtk-demo/sliding_puzzle.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c index 925d981764..c7897f2dfd 100644 --- a/demos/gtk-demo/sliding_puzzle.c +++ b/demos/gtk-demo/sliding_puzzle.c @@ -355,11 +355,16 @@ reshuffle (void) { GtkWidget *grid; - grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame)); if (solved) - start_puzzle (puzzle); + { + start_puzzle (puzzle); + grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame)); + } else - shuffle_puzzle (grid); + { + grid = gtk_aspect_frame_get_child (GTK_ASPECT_FRAME (frame)); + shuffle_puzzle (grid); + } gtk_widget_grab_focus (grid); } -- 2.30.2